package org.javaweb.cms_web.service;

import org.javaweb.cms_web.mapper.TeamMapper;
import org.javaweb.cms_web.mapper.UserMapper;
import org.javaweb.cms_web.model.Team;
import org.javaweb.cms_web.model.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TeamService {
    @Resource
    private TeamMapper teamMapper;
    @Resource
    private UserMapper userMapper;

    public List<Team> getAllTeams() {
        return teamMapper.selectAllTeams();
    }

    //模糊查询团队
    public List<Team> getTeamsBySearch(String search) {
        return teamMapper.getTeamsBySearch(search);
    }

    //根据团队ID查询团队
    public Team getTeamById(int teamId) {
        return teamMapper.selectTeamById(teamId);  // 使用Mapper查询团队详情
    }

    //根据团队ID查询团队成员
    public List<String> getTeamMembers(int teamId) {
        return teamMapper.getTeamMembers(teamId);  // 使用Mapper查询团队成员
    }

    public void updateTeamInfo(Team team) {
        teamMapper.updateTeam(team);
    }

    public List<User> getTeamMembersDetail(Integer teamId) {
        return userMapper.selectUsersByTeamId(teamId);
    }
}
